﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;

/// <summary>
/// Summary description for ProductBus
/// </summary>
public class ProductBus
{
    
ProductDAL productDAL = new ProductDAL();
    public ProductBus()
    {
        //
        // TODO: Add constructor logic here
        //
    }
    //display all product
    public DataTable GetAllProduct()
    {
        return productDAL.GetAllProduct();
    }
    //search Product by Id
    public DataTable GetProductDetailById(string productId)
    {
        DataTable dt = new DataTable();


        return productDAL.GetProductById(productId);
    }
    //search product by img
    public DataTable GetProductDetailByImg(string img)
    {
        DataTable dt = new DataTable();


        return productDAL.GetProductByImg(img);
    }
    //search Product by 
    public DataTable GetProductDetailAll(string categoryname, string color1, string color2, string color3, string color4, int size1, int size2, int size3, int size4, float price1, float price2)
    {
        DataTable dt = new DataTable();


        return productDAL.GetProductAll(categoryname, color1, color2, color3, color4, size1, size2, size3, size4, price1, price2);
    }
    //search Product by name and id
    public string GetProductDetailsByNameandId(string productname, string productid)
    {
        DataTable table = new DataTable();

        table = productDAL.GetFlowerByNameandId(productname, productid);
        if (table.Rows.Count != 0)
        {
            return table.Rows[0]["ProductId"].ToString();
        }
        return "";
    }
    public DataTable GetUrlImgByCategoryName(string urlimg)
    {
        DataTable dt = new DataTable();
        return productDAL.GetUrlImgbyCategoryName(urlimg);
    }

    public DataTable GetProductDetail(string size1, string color1, float price1, float price2, string CategoryName)
    {
        DataTable dt = new DataTable();
        return productDAL.GetSearchAll01(size1, color1, price1, price2, CategoryName);
    }

    public DataTable GetProductIdByProductName(string ProductName)
    {
        DataTable dt = new DataTable();
        return productDAL.GetProductByName(ProductName);
    }
    //add product
    public string addProduct(Product product)
    {
        if (productDAL.InsertProduct(product) == 0)
        {
            return "Add Fail !";
        }
        else
        {
            return "Add new product successull !";
        }
    }





  
}
